﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using WindowsPhoneApp;
using System.Windows.Media.Imaging;

namespace WindowsPhoneAppHost
{
    public partial class OaTypeItem : UserControl
    {
        //string titleText;
        string nextXamlPageName;

        public OaTypeItem()
        {
            InitializeComponent();
        }

        public string TitleText
        {
            get { return this.text.Text; }
            set
            {
                this.text.Text = value;
            }
        }  

        public string ImageSource
        {
            get { return this.icon.Source.ToString(); }
            set
            {
                //Uri uri = new Uri("ftp://" + value, UriKind.Absolute);
                Uri uri = new Uri(@"..\" + value, UriKind.Relative);
                this.icon.Source = new BitmapImage(uri); 
            }
        }

        public string XamlPageName
        {
            get { return this.nextXamlPageName; }
            set
            {
                this.nextXamlPageName = value;
            }
        }
        
        private void RootButton_Click(object sender, RoutedEventArgs e)
        {
            if (null != nextXamlPageName && nextXamlPageName.Length > 0)
            {
                Common.navigateTo("/../" + nextXamlPageName);
            }
            else
            {
                MessageBox.Show("RootButton_Click");
            }
        }            
    }
}
